<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <script>
  //方式一：隐式转化
  var num1="8"
  var num2="4"
  var result =num1+num2//显示84，字符串拼接
  console.log(result)
  console.log(typeof result)
  var result2= num1*num2//32
  console.log(result2)
  console.log(typeof result2)
  console.log("========================")
  //方式二：显示转化
console.log(Number(num1))
console.log(typeof Number(num1))
//其他类型转化为数字的类型的规则
console.log("============================")
console.log(Number (undefined))
console.log(Number(true))
console.log(Number(false))
console.log(Number(null))
console.log(Number("abc123"))
console.log(Number("123"))
console.log(Number("   123"))
  </script>
</body>
</html>